<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="../js/jquery-1.12.1.js"></script>
</head>
<body>
<form method="post" onsubmit="check()">
  <p>
    用户名：<input id="username" type="text" name="username" />
  </p>
  <p>
    密码：<input id="pwd" type="password" name="pwd" />
  </p>
  <p>
    确认密码：<input id="confirmPwd" type="password" name="confirmPwd" />
  </p>
  <p>
    <input type="submit" value="注册">
  </p>
</form>
<script>
  function check() {
    var pwd = $("#pwd").val();
    console.log(pwd)
    if ($("#username").val() !== "" && pwd !=="" && pwd === $("#confirmPwd").val()) {
      alert("注册成功！");
    } else {
      alert("输入有误！");
    }
  }
</script>
</body>
</html>